package nf.graph;

/**
 * Represents an edge in a graph.
 */
public class Edge
{
	private Node head;
	private Node tail;
	
	public Edge(Node head, Node tail)
	{
		this.head = head;
		this.tail = tail;
	}
	
	public Node getHead()
	{
		return head;
	}
	
	public Node getTail()
	{
		return tail;
	}
	
	public boolean equals(Edge other)
	{
		return (head.equals(other.getHead()) && tail.equals(other.getTail()));
	}
	
	public boolean equals(Object other)
	{
		return (other instanceof Edge)
			? equals((Edge) other)
			: false;
	}
	
	public String toString()
	{
		return String.format("(%s -> %s)", head.getName(), tail.getName());
	}
}
